import request from "@/api";
import type {IApiResponse} from "@/types";
import type {ILoginFormData, ILoginResponse} from "@/types/sign";


/**
 * Token 获取
 * @param formData
 */
export const userLoginApi = (formData: ILoginFormData): Promise<IApiResponse<ILoginResponse>> => {
    return request({
        method: "POST",
        url: "/token/",
        data: formData
    })
}


/**
 * Token 刷新
 * @param refreshToken
 */
export const userLoginRefreshApi = (refreshToken: string): Promise<IApiResponse<any>> => {
    return request({
        method: "POST",
        url: "/token/refresh/",
        data: refreshToken
    })
}


/**
 * Token 校验
 * @param accessToken
 */
export const userLoginVerifyApi = (accessToken: string): Promise<IApiResponse<any>> => {
    return request({
        method: "POST",
        url: "/token/verify/",
        data: accessToken
    })
}


/**
 * 获取用户信息
 */
export const getUserInfoApi = (): Promise<IApiResponse<any>> => {
    return request({
        method: "GET",
        url: "/system/users/profile/",
    })
}


/**
 * 获取用户菜单
 */
export const getUserMenuApi = (): Promise<IApiResponse<any>> => {
    return request({
        method: "GET",
        url: "/system/users/menus/",
    })
}


/**
 * 获取用户权限列表
 */
export const getUserPermissionApi = (): Promise<IApiResponse<any>> => {
    return request({
        method: "GET",
        url: "/system/users/permissions/",
    })
}
